#pragma once

#include "TileState.h"

#include <Windows.h>

#define INVALID_TILE_COORDS -1L

#define TILE_ARRAY_COL(l)           ((WORD)(((DWORD_PTR)(l)) & 0xffff))
#define TILE_ARRAY_LINE(l)          ((WORD)((((DWORD_PTR)(l)) >> 16) & 0xffff))
#define TILE_ARRAY_COORDS(l, c)		((LONG)(((WORD)(((DWORD_PTR)(c)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(l)) & 0xffff))) << 16))

class Tile
{
protected:
	RECT mSquare;
	char mLetter;
	TileState mState;
	UINT mLine;
	UINT mCol;

public:
	Tile(int _x, int _y, int _size, UINT _line, UINT _col);
	Tile(RECT& _rect);
	~Tile(void);

	virtual void Render(HDC _surface) = 0;

	const RECT& Rect() { return mSquare; }
	int X() { return mSquare.left; }
	int Y() { return mSquare.top; }
	void Pos( int _x, int _y);

	bool ContainsPoint(int _x, int _y);

	char Letter() { return mLetter; }
	void Letter(char _newLetter);
	UINT Line() const { return mLine; }
	UINT Col() const { return mCol; }

	TileState& State();

	void Clone(Tile* _tile);


};
